package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.lxj.xpopup.core.BasePopupView;
import com.seuic.hnjiningposapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 联网核查结果
 */
public class IdInfoPp extends BasePopupView {
    Unbinder bind;
    @BindView(R.id.user_info_jg)
    TextView userInfoJg;
    @BindView(R.id.id_ImageView)
    ImageView idImageView;
    @BindView(R.id.user_info_name)
    TextView userInfoName;
    @BindView(R.id.user_info_id)
    TextView userInfoId;
    @BindView(R.id.identity_indo_okbtn)
    Button identityIndoOkbtn;
    Context mContext;
    OnSureIdInfo mOnSureIdInfo;

    public IdInfoPp(@NonNull Context context, OnSureIdInfo onSureIdInfo) {
        super(context);
        this.mContext = context;
        this.mOnSureIdInfo = onSureIdInfo;
    }

    @Override
    protected int getPopupLayoutId() {
        return R.layout.identity_indo_layout;
    }

    @OnClick(R.id.identity_indo_okbtn)
    public void onViewClicked() {
        mOnSureIdInfo.SureIdInfo();
    }



    public void setmInfoJg(String mInfoJg) {
        this.mInfoJg = mInfoJg;
    }

    public void setmInfoName(String mInfoName) {
        this.mInfoName = mInfoName;
    }

    public void setmInfoId(String mInfoId) {
        this.mInfoId = mInfoId;
    }


    String mInfoJg;//审核结果
    String mInfoName;//姓名
    String mInfoId;//身份证号
    String mIdImg;
    public void setmIdImg(String mIdImg) {
        this.mIdImg = mIdImg;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        bind = ButterKnife.bind(this);
        userInfoJg.setText(mInfoJg);//审核结果
        userInfoName.setText(mInfoName);
        userInfoId.setText(mInfoId);
        //将Base64编码字符串解码成Bitmap
        byte[] decodedString = Base64.decode(mIdImg, Base64.DEFAULT);
        Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
        //设置ImageView图片
        idImageView.setImageBitmap(decodedByte);

//        Glide.with(mContext).load(mIdImg).into(idImageView);


    }

    public interface OnSureIdInfo {
        void SureIdInfo();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        //注解解绑
        if (bind != null && bind != Unbinder.EMPTY) {
            bind.unbind();
        }
        this.bind = null;
    }
}
